package org.thirdHero.db.domain;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * 表名 sys_code
 * @author Administrator
 * @创建时间： 2019-08-20
 */
public class SysCode {
    /**
     * 主键
     */
    private String id;

    /**
     * 创建日期
     */
    private LocalDateTime createDate;

    /**
     * 修改日期
     */
    private LocalDateTime modifyDate;

    /**
     * 父类code
     */
    private String parentCode;

    /**
     * code值
     */
    private String code;

    /**
     * 名称
     */
    private String codeName;

    /**
     * 所属群
     */
    private String groupCode;

    /**
     * 
     */
    private String desc;

    /**
     * 是否删除
     */
    private Integer deleted;

    /**
     * 主键
     * @return id 主键
     */
    public String getId() {
        return id;
    }

    /**
     * 主键
     * @param id 主键
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * 创建日期
     * @return create_date 创建日期
     */
    public LocalDateTime getCreateDate() {
        return createDate;
    }

    /**
     * 创建日期
     * @param createDate 创建日期
     */
    public void setCreateDate(LocalDateTime createDate) {
        this.createDate = createDate;
    }

    /**
     * 修改日期
     * @return modify_date 修改日期
     */
    public LocalDateTime getModifyDate() {
        return modifyDate;
    }

    /**
     * 修改日期
     * @param modifyDate 修改日期
     */
    public void setModifyDate(LocalDateTime modifyDate) {
        this.modifyDate = modifyDate;
    }

    /**
     * 父类code
     * @return parent_code 父类code
     */
    public String getParentCode() {
        return parentCode;
    }

    /**
     * 父类code
     * @param parentCode 父类code
     */
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

    /**
     * code值
     * @return code code值
     */
    public String getCode() {
        return code;
    }

    /**
     * code值
     * @param code code值
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * 名称
     * @return code_name 名称
     */
    public String getCodeName() {
        return codeName;
    }

    /**
     * 名称
     * @param codeName 名称
     */
    public void setCodeName(String codeName) {
        this.codeName = codeName;
    }

    /**
     * 所属群
     * @return group_code 所属群
     */
    public String getGroupCode() {
        return groupCode;
    }

    /**
     * 所属群
     * @param groupCode 所属群
     */
    public void setGroupCode(String groupCode) {
        this.groupCode = groupCode;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 是否删除
     * @return deleted 是否删除
     */
    public Integer getDeleted() {
        return deleted;
    }

    /**
     * 是否删除
     * @param deleted 是否删除
     */
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", createDate=").append(createDate);
        sb.append(", modifyDate=").append(modifyDate);
        sb.append(", parentCode=").append(parentCode);
        sb.append(", code=").append(code);
        sb.append(", codeName=").append(codeName);
        sb.append(", groupCode=").append(groupCode);
        sb.append(", desc=").append(desc);
        sb.append(", deleted=").append(deleted);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysCode other = (SysCode) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCreateDate() == null ? other.getCreateDate() == null : this.getCreateDate().equals(other.getCreateDate()))
            && (this.getModifyDate() == null ? other.getModifyDate() == null : this.getModifyDate().equals(other.getModifyDate()))
            && (this.getParentCode() == null ? other.getParentCode() == null : this.getParentCode().equals(other.getParentCode()))
            && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
            && (this.getCodeName() == null ? other.getCodeName() == null : this.getCodeName().equals(other.getCodeName()))
            && (this.getGroupCode() == null ? other.getGroupCode() == null : this.getGroupCode().equals(other.getGroupCode()))
            && (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode());
        result = prime * result + ((getModifyDate() == null) ? 0 : getModifyDate().hashCode());
        result = prime * result + ((getParentCode() == null) ? 0 : getParentCode().hashCode());
        result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
        result = prime * result + ((getCodeName() == null) ? 0 : getCodeName().hashCode());
        result = prime * result + ((getGroupCode() == null) ? 0 : getGroupCode().hashCode());
        result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    /**
     * sys_code
     */
    public enum Column {
        id("id", "id", "VARCHAR", false),
        createDate("create_date", "createDate", "TIMESTAMP", false),
        modifyDate("modify_date", "modifyDate", "TIMESTAMP", false),
        parentCode("parent_code", "parentCode", "VARCHAR", false),
        code("code", "code", "VARCHAR", false),
        codeName("code_name", "codeName", "VARCHAR", false),
        groupCode("group_code", "groupCode", "VARCHAR", false),
        desc("desc", "desc", "VARCHAR", true),
        deleted("deleted", "deleted", "INTEGER", false);

        /**
         */
        private static final String BEGINNING_DELIMITER = "`";

        /**
         */
        private static final String ENDING_DELIMITER = "`";

        /**
         */
        private final String column;

        /**
         */
        private final boolean isColumnNameDelimited;

        /**
         */
        private final String javaProperty;

        /**
         */
        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }
    }
}